package com.leetcode;

/**
 * 191. 位1的个数
 * 循环检查二进制位
 */
public class Solution191 {
    public int hammingWeight(int n) {
        int count = 0;
        for (int i = 0; i < 32; i++) {
            if (((1 << i) & n) != 0) {
                count++;
            }
        }
        return count;
    }
}
